/**
 * Created by denh on 16/12/13.
 */

var token = '<?=$this->token?>';
var page = 0;

var appList = new Vue({
    el: '#list',
    data: {
        messages: [],
        name : "hello vue"
    },
    methods : {
        detailUrl : function(id){
            common.redirect('meeting', 'detail', 'id='+id);
        }
    }
});

$(window).scroll(function(){
    // var afterScrollTop = document.body.scrollTop;

    if ($(document).height() - $(document).scrollTop() - document.body.clientHeight == 0) {
        if (page != -1) {
            // console.log('page:'+page);
            getData();
        }
    }
});
getData();
function getData() {
    common.serverUrl = '<?=BACK_INTERFACE_BASE_URL?>';
    $.get(common.url('meeting', 'meetingList'), {page:page}, function(result){
        console.log(result);
        if(result.code == 0){
            var message = result.result.cardList;
            for (i=0; i<message.length; i++) {
                pic = eval('(' + message[i]['pic'][0] + ')');
                message[i]['detailUrl'] = common.url('meeting', 'detail', 'id='+message[i]['id']);
                message[i]['picUrl'] = pic['url'];
                message[i]['meetingTime'] = common.getDate(message[i]['meetingExt']['startTime']) + ' - ' +common.getDate(message[i]['meetingExt']['endTime']);
                appList.messages.push(message[i]);
            }

            if (message.length == 10) {
                page++;
            } else {
                page = -1
            }
            console.log(page);
        }
    }, 'json');
}

wx.config({
    debug: false,
    appId: '<?php echo $this->signPackage["appId"];?>',
    timestamp: '<?php echo $this->signPackage["timestamp"];?>',
    nonceStr: '<?php echo $this->signPackage["nonceStr"];?>',
    signature: '<?php echo $this->signPackage["signature"];?>',
    jsApiList: [
    'onMenuShareAppMessage',
    'onMenuShareTimeline',
    'onMenuShareQQ',
    'onMenuShareWeibo',
    'onMenuShareQZone'
    ]
});

title = '爱贝儿医-爱会议！';
desc = '爱贝儿医—专注于做儿科医生间学习工作交流平台。平台拥有数十位来自省级以上重点三甲医院的儿科专家、重点医院儿科学科带头人、国内儿科权威人士组成的豪华专家团队。';
links = '';
imgUrl = '<?=G_SITE_CDN?>/business/img/logoRed2.png';

weixinShare(title, desc, links, imgUrl);